package org.display.graphic
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	public class HitRect extends Sprite
	{
		var container:ShapeBase
		
		public function HitRect(container)
		{
			
			this.container=container
				
			with(this){
			graphics.lineStyle(1,0x000000,0)
			graphics.beginFill(0x666666,1)
			graphics.drawRect(0,0,10,10)
			graphics.endFill()
			alpha=0
			}
			
			buttonMode=true
			useHandCursor=true
				
			addEventListener(MouseEvent.MOUSE_DOWN,mouseEvent)
			
		}
		
		
		function mouseEvent(e:MouseEvent){
			
			switch(e.type){
				
				case MouseEvent.MOUSE_DOWN:
					
					this.startDrag(false)
					stage.addEventListener(MouseEvent.MOUSE_UP,mouseEvent)
					stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseEvent)
					break
				
				
				case MouseEvent.MOUSE_UP:
					this.stopDrag()
					stage.removeEventListener(MouseEvent.MOUSE_UP,mouseEvent)
					stage.removeEventListener(MouseEvent.MOUSE_MOVE,mouseEvent)
					break
				
				
				case MouseEvent.MOUSE_MOVE:
					
					if(x<10){x=10;this.stopDrag()}
					if(y<10){y=10;this.stopDrag()}
					
					container.redraw(x+10,y+10)
					
					break
				
			}
			
		}
	}
}